/**
 * 
 */
package org.hospital.action;

import java.util.List;

import org.hospital.dao.IPatientDAO;
import org.hospital.pojo.TPatient;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author HuangKai
 *
 */
public class QueryPatientAction {
	private AbstractApplicationContext aac = new ClassPathXmlApplicationContext(
	"applicationContext.xml");
	
	private TPatient patient;

	public TPatient getPatient() {
		return patient;
	}

	public void setPatient(TPatient patient) {
		this.patient = patient;
	}
	
	public String execute() throws Exception {
		
		IPatientDAO patientDao = (IPatientDAO) aac.getBean("PatientDAO");
		List patientList = patientDao.findByProperty("idNum", patient.getIdNum());
		
		if (patientList!=null&&!patientList.isEmpty()){
			patient = (TPatient) patientList.get(0);
			if (patient!=null){
				return "success";
			}
		}else{
			return "error";
		}
		
		return "error";
	}
}
